// $(function () {
//     $("#resume_section").change(function () {
//
//     });
// });

function findPositions() {
    var sId = $("#resume_section").val();
    if (sId === "") {
        $("#resume_position").val("");
    } else {
        $.post("../user/positions",
            "sId=" + sId,
            function (data) {
                console.log(data);
                $("#resume_position").html("");
                for (var i = 0, n = data.length; i < n; i++) {
                    $("#resume_position").append("<option value='" + data[i].id + "'>" + data[i].position + "</option>");
                }
            });
    }
}

function checkResumeForm() {
    var $error = $("#resume_error");
    var $sub = $("#resume_submit");
    var realName = $("#resume_real_name").val();
    var sex = $("input[name=sex]:checked").val();
    var age = $("#resume_age").val();
    var education = $("#resume_education").val();
    var email = $("#resume_email").val();
    var position = $("#resume_position").val();
    var politics = $("#resume_politics").val();
    var lastJop = $("#resume_last_jop").val();
    var experience = $("#resume_experience").val();
    var hobbies = $("#resume_hobbies").val();
    var reg = /^[1-9][0-9]$/;
    var reg0 = /^\w{3,9}@\w{2,3}(\.[a-zA-Z]{3}){1,2}$/;
    var reg1 = /^[1-9][0-9]?\.?[0|5]?/;
    console.log("sex = " + sex);
    if (realName === '') {
        isError($error, $sub, "请填入真实姓名！");
        return false;
    }
    if (sex === '' || sex === undefined) {
        isError($error, $sub, "请选择性别！");
        return false;
    }
    if (age === '') {
        isError($error, $sub, "请填入年龄！");
        return false;
    }
    if (reg.test(age) === false || age < 18) {
        isError($error, $sub, "年龄输入格式不正确，请重试！");
        return false;
    }
    if (education === '') {
        isError($error, $sub, "请选择学历！");
        return false;
    }
    if (email === '') {
        isError($error, $sub, "请输入您的邮箱！");
        return false;
    }
    if (reg0.test(email) === false) {
        isError($error, $sub, "邮箱输入格式不正确，请重试！例：123asd@qwe.asd.zxc或123asd@qwe.asd");
        return false;
    }
    if (position === '') {
        console.log("position = " + position);
        isError($error, $sub, "请选择您要应聘的职位！");
        return false;
    }
    if (politics === '') {
        isError($error, $sub, "请选择您的政治面貌！");
        return false;
    }
    if (lastJop === '') {
        isError($error, $sub, "请填写您的上一份工作！");
        return false;
    }
    if (experience === '') {
        isError($error, $sub, "请填写您的工作经验！");
        return false;
    }
    if (reg1.test(experience) === false) {
        isError($error, $sub, "工作经验输入格式不正确，请重试！例：3 或 3.5");
        return false;
    }
    if (hobbies === '') {
        isError($error, $sub, "请填写您的兴趣爱好！");
        return false;
    }
    $error.html("输入正确，允许提交！").css("color", "rgba(0,230,120,0.7)");
    $sub[0].disabled = false;
    return true;
}